<?php
/*
 *  A Part of snock project
 *   Author king-of-war
 * Last modified 2009-4-21
 *
 */
 @session_start();
 echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';

 $root_path='../';
 include_once $root_path . 'admin/smarty_config.php';
include_once $root_path . 'admin/class/fun_common.php';
include_once $root_path . 'admin/class/sort.class.php';
$sort=new sort($root_path);
$fun = new fun_common($root_path);

$max = $fun->getAll('products_sort', 1);

/*
 *
 * check identify
 */
include_once $root_path.'admin/class/verify.class.php';
$a=new verify($root_path);
$a->identity_check(3);

/*
 * page moudle start
 *
 */
  include_once $root_path . 'admin/class/cfg.class.php';
$cfg=new cfg($root_path);
  $page_size=$cfg->xml_read('page_num');
if (!empty ($_GET['p'])) {
	$page = $_GET['p'];
} else {
	$page = 1;
}
$pages = $fun->page($page, $page_size, $max);
/*
 * page moulde  end
 *  sort_read($arr)
 */

$arr[0] = $pages['start'];
$arr[1] = $page_size;
/*
 * get the comment of sorts
 */
$sorts=array();

$pass=$sort->sort_read($arr);

for($i=0;$i<count($pass);$i++){
	$sorts[$i]['id']=$pass[$i]->get_id();
    $sorts[$i]['name']=$pass[$i]->get_name();
  $sorts[$i]['intro']=$pass[$i]->get_intro();
}

/*
 * sort delete moudle
 */

if (isset($_POST['Submit'])) {

//	$ids = array ();
		$t=0;
	for ($i = 0; $i < $max; $i++) {

		$id = $sorts[$i]['id'];

		if ($_POST[$id]!= '') {

			$ids[$t]=$id;
			$t++;
		}

	}
print_r($ids);

	 $line=$sort->sort_del($ids);


if($line){
	echo '<div align="center"><h1>成功删除'.$line.'条产品分类</h1></div>';
}else{
	echo '<div align="center"><h1>删除失败</h1></div>';
};
}


$smarty->assign("sorts", $sorts);
$smarty->assign("page", $pages);
$smarty->assign("url", $root_path);
$smarty->display("sort_del.html");

?>
